package com.example.myapplication.apter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.myapplication.R;
import com.example.myapplication.ShuJu.ListfvehiclesBean;

import java.util.List;

public class ListfvehiclesApter extends RecyclerView.Adapter<ListfvehiclesApter.Myhot>{
    private Context context;
    private List<ListfvehiclesBean.RowsBean> list;
    private List<String> stringList;

    public ListfvehiclesApter( List<ListfvehiclesBean.RowsBean> list,Context context,List<String> strings) {
        this.context = context;
        this.list = list;
        this.stringList = strings;
    }

    @NonNull
    @Override
    public Myhot onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(context).inflate(R.layout.item_istfvehicles, null);
        return  new ListfvehiclesApter.Myhot(inflate);
    }

    @Override
    public void onBindViewHolder(@NonNull Myhot holder, int position) {
            holder.licensenum.setText(String.valueOf(list.get(position).getPlateNo()));
            holder.kilometres.setText(list.get(position).getTravelDistance());

    }

    @Override
    public int getItemCount() {
        return list==null?0:list.size();
    }

    class Myhot extends RecyclerView.ViewHolder{

        private final TextView licensenum;
        private final TextView framenumber;
        private final TextView phonnume;
        private final TextView cattype;
        private final TextView kilometres;

        public Myhot(@NonNull View itemView) {
            super(itemView);
            licensenum = itemView.findViewById(R.id.Licensenum);
            framenumber = itemView.findViewById(R.id.Framenumber);
            phonnume = itemView.findViewById(R.id.phonnume);
            cattype = itemView.findViewById(R.id.cattype);
            kilometres = itemView.findViewById(R.id.kilometres);
        }
    }
}
